#ifndef DSPNASM_INSTGENERATOR_H
#define DSPNASM_INSTGENERATOR_H

#include "NasmBaseVisitor.h"
#include "nasm/elf/elfFile.h"
#include "nasm/symbol/symbolTable.h"
#include "nasm/instruction/generator.h"
#include "nasm/operand/operand.h"

namespace dspnasm {
    class InstGenerator : public NasmBaseVisitor {
    private:
        std::shared_ptr<ElfFile> m_elfFile;
        std::shared_ptr<SymbolTable> m_symbolTable;
        std::shared_ptr<Generator> m_generator;
        std::string m_segmentName;   // 当前分析到的段名称
        u32 m_offset;   // 当前分析到的段偏移
        u32 m_assemblyAddress; // 当前分析到的汇编地址
        u32 m_curSize;  // 当前的指令尺寸
    public:
        InstGenerator(std::shared_ptr<SymbolTable> symbolTable, std::shared_ptr<ElfFile> elfFile);

        ~InstGenerator() override = default;

        antlrcpp::Any visitType(NasmParser::TypeContext *ctx) override;

        antlrcpp::Any visitOperand(NasmParser::OperandContext *ctx) override;

        antlrcpp::Any visitDeclare(NasmParser::DeclareContext *ctx) override;

        antlrcpp::Any visitInstructionPacket(NasmParser::InstructionPacketContext *ctx) override;

        antlrcpp::Any visitNum(dspnasm::NasmParser::NumContext *ctx) override;
    };
}

#endif //DSPNASM_INSTGENERATOR_H
